package com.huan.springboot;

import com.huan.springboot.properties.MultiMongoProperties;
import com.huan.springboot.repository.persons.PersonRepository;
import com.huan.springboot.repository.study.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

/**
 * 引用启动入口
 *
 * @author huan.fu
 * @date 2018/4/24 - 14:56
 */
@SpringBootApplication
@EnableConfigurationProperties(MultiMongoProperties.class)
@Slf4j
public class Application implements CommandLineRunner {

	@Autowired
	private PersonRepository personRepository;
	@Autowired
	private UserRepository userRepository;

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		log.info("开始从persons库中获取pers集合的信息");
		personRepository.findAll().stream().forEach(System.out::println);
		log.info("开始从study;库中获取users集合中的信息");
		userRepository.findAll().stream().forEach(System.out::println);
	}
}
